home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 83 / MacAddict_083_2003-07.iso / mac / Software / Development / VLC Source 0.5.3.dmg / extras / MacOSX / macosx-dmg
Text File  |  2003-03-24  |  1KB  |  54 lines

  1. #!/bin/sh
  2. #
  3. # Posted to the projectbuilder-users list by Mike Ferris
  4. # Modified for vlc by Jon Lech Johansen
  5. #
  6.  
  7. set -e
  8.  
  9. # Requires at least three args
  10. if [ $# -lt 3 ] ; then
  11.     echo "usage: $0 size name file ..." 1>&2
  12.     exit 1
  13. fi
  14.  
  15. # Grab size and name
  16. imgSize=$1
  17. shift
  18. imgName=$1
  19. shift
  20.  
  21. if [ $((${imgSize} < 5)) != 0 ] ; then
  22.     imgSize=5;
  23. fi
  24.  
  25. # Create the image and format it
  26. rm -f "${imgName}.dmg"
  27. echo; echo "Creating ${imgSize} MB disk image named ${imgName}"
  28. hdiutil create "${imgName}.dmg" -megabytes "${imgSize}" -layout NONE -quiet
  29. dev=`hdid -nomount "${imgName}.dmg" | grep '/dev/disk[0-9]*' | cut -d " " -f 1`
  30. /sbin/newfs_hfs -w -v "${imgName}" -b 4096 "${dev}" > /dev/null
  31. hdiutil eject "${dev}" -quiet
  32.  
  33. # Mount the image and copy stuff
  34. dev=`hdid "${imgName}.dmg" | grep '/dev/disk[0-9]*' | cut -d " " -f 1`
  35.  
  36. echo "Copying contents to ${imgName}:"
  37. while [ $# -gt 0 ] ; do
  38.     echo "  ${1}"
  39.     /Developer/Tools/CpMac -r "${1}" "/Volumes/${imgName}"
  40.     shift
  41. done
  42.  
  43. hdiutil eject "${dev}" -quiet
  44.  
  45. # Compress the image
  46. echo "Compressing ${imgName} disk image"
  47. mv "${imgName}.dmg" "${imgName}.orig.dmg"
  48. hdiutil convert "${imgName}.orig.dmg" -format UDZO -o "${imgName}" -quiet
  49. rm "${imgName}.orig.dmg"
  50.  
  51. # Done
  52. echo; echo "Disk image creation completed:"
  53. ls -la "${imgName}.dmg"; echo
  54.